Skip to main content

std.boolean

Pebble 0.3.1 · all symbols on this page are stable.

Monomorphic helpers over bool. Prefer the operator forms (&&, ||, !) in regular code — these exist for partial application and higher-order use.

Methods

FunctionDescription
not(b: bool): boolLogical NOT.
strictAnd(a: bool, b: bool): boolLogical AND. Strict in both arguments — unlike && which short-circuits, both a and b are evaluated.
strictOr(a: bool, b: bool): boolLogical OR. Strict in both arguments — unlike ||.
equals(a: bool, b: bool): boolTrue iff a and b have the same value.
toInt(b: bool): int0 for false, 1 for true.
Strict vs short-circuit

strictAnd / strictOr evaluate both operands. If either argument can fail or perform an expensive computation, use the operator forms && / || which short-circuit.

Examples

using { not, strictAnd, strictOr, equals, toInt } = std.boolean;

const n: bool = not(true); // false
const a: bool = strictAnd(true, false); // false
const o: bool = strictOr(true, false); // true
const eq: bool = equals(true, true); // true
const i: int = toInt(true); // 1

See also

  • bool — operator forms
  • std.builtinsifThenElse is the strict polymorphic conditional